package jwdt.xadmin.added.service.impl;

import jwdt.common.dao.BaseDao;
import jwdt.xadmin.added.bean.TLink;
import jwdt.xadmin.added.service.LinkManageService;

import com.ezerg.db.ext.PageUtil;

public class LinkManageServiceImpl implements LinkManageService{
	private BaseDao<TLink> baseDao;
	
	public void setBaseDao(BaseDao<TLink> baseDao) {
		this.baseDao = baseDao;
	}
	@Override
	public PageUtil doList(PageUtil pu, TLink l) throws Exception{
		String sql = " order by id asc";
		Integer id = l.getLinktype();
		if(id != null && id!=0) {
			sql = "linktype=" + id + sql;
		}
		pu.doList(TLink.class,sql);
		//创造json数据对象
		return pu;
	}
	@Override
	public String doAddact(TLink obj) throws Exception {
		return baseDao.doAddObj(obj);
	}

	@Override
	public String doEditact(TLink obj, int id) throws Exception {
		return baseDao.doUpdateObj(TLink.class, id, obj);
	};
	
	@Override
	public String doDelact(int id) throws Exception {
		return baseDao.doDelObj(TLink.class, id);
	}

	@Override
	public TLink doLoad(int id) throws Exception {
		return baseDao.doLoadObj(TLink.class, id);
	}
	@Override
	public String doUpdateState(int id, String result) throws Exception {
		return baseDao.doIntUpdateState(TLink.class, "id="+id, result);
	}
}
